// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  modules: ["@unocss/nuxt", "@nuxt/icon", "@pinia/nuxt", "@nuxtjs/sitemap", "@nuxtjs/i18n"],
  i18n: {
    locales: [
      { code: "en", language: "en-US", file: "en.json", name: "英文" },
      { code: "zh", language: "zh-CN", file: "zh.json", name: "中文" },
    ],
    defaultLocale: "zh",
  },
  compatibilityDate: "2025-07-15",
  devtools: { enabled: true },
  icon: {
    localApiEndpoint: "/nuxt-icon",
  },
  app: {
    head: {
      title: "Nuxt4-Test",
      meta: [
        { name: "description", content: "Nuxt4-Test" },
        { name: "keywords", content: "Nuxt, Vue, Nuxt4, Nuxt-Icon" },
        { name: "viewport", content: "width=device-width, initial-scale=1" },
      ],
    },
  },
  ssr: true,
  devServer: {
    port: 3000,
  },
  css: ["~/assets/index.css"],
  nitro: {
    // 代理，前后端分离有用
    /* devProxy: {
      "/api": {
        target: "http://localhost:3000",
        changeOrigin: true,
        prependPath: true,
      },
    }, */
  },
  site: {
    url: "http://localhost:3000",
    name: "localhost",
  },
  sitemap: {
    sources: ["/api/__sitemap__/urls"],
    exclude: ["/login/**"],
    cacheMaxAgeSeconds: 6 * 60 * 60,
    autoLastmod: true,
    // 添加更多配置
    defaults: {
      changefreq: "weekly",
      priority: 0.8,
      lastmod: new Date(),
    },
    // 确保sitemap可以被搜索引擎访问
    xslColumns: [
      { label: "URL", width: "50%" },
      { label: "Last Modified", select: "sitemap:lastmod", width: "25%" },
      { label: "Priority", select: "sitemap:priority", width: "12.5%" },
      { label: "Change Frequency", select: "sitemap:changefreq", width: "12.5%" },
    ],
  },
});
